const {ipcRenderer} = require('electron');
ipcRenderer.on('progress', (event, arg) => {
    $('#progress_container').append('<h6>' + arg + '</h6>')
});
ipcRenderer.on('finish', (event, arg) => {
    $('#link_download').attr('href', arg);
    $('#img_fire').attr('alt','下载');
    $('#progress_container').append('<h6>点击火焰下载</h6>')
});
$(function () {
    var files = {};
    $("#file_office").change(function (e) {
        var name = e.target.files[0].name;
        $('#input_office').val(name);
        files['office'] = e.target.files[0].path;
    })
    $("#file_location").change(function (e) {
        var name = e.target.files[0].name;
        $('#input_location').val(name);
        files['location'] = e.target.files[0].path;
    })
    $("#file_business").change(function (e) {
        var name = e.target.files[0].name;
        $('#input_business').val(name);
        files['business'] = e.target.files[0].path;
    })
    $("#file_product").change(function (e) {
        var name = e.target.files[0].name;
        $('#input_product').val(name);
        files['product'] = e.target.files[0].path;
    })
    $('#btn_make_db').click(function () {
        if (Object.keys(files).length < 4) {
            // alert('数据表必须全部选择');
            toastr.error('数据表必须全部选择');
            return
        }
        $('#progress_container').html('');
        $('#link_download').removeAttr('href');
        $('#img_fire').attr('alt','');
        ipcRenderer.send('makeDb', files);
    });

});